package com.cloudstore.app.no0000149;

import java.io.IOException;
import java.io.PrintWriter;
import weaver.general.BaseBean;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import weaver.conn.RecordSet;

public class ValidateName extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html");
        String wjbt = request.getParameter("wjbt");
		String wfid = request.getParameter("formid");
		String result="";
        String backsql="select formid,fieldid from uf_wf_validate where formid='"+wfid+"'";
        System.out.println("backsql:"+backsql);
		RecordSet backrs = new RecordSet();
		backrs.executeSql(backsql);
		backrs.next();
		String formid=backrs.getString("formid");
		String fieldid=backrs.getString("fieldid");
		String sql = "select requestId,"+fieldid+" from "+formid+" where "+fieldid+"='"+wjbt+"'";
		System.out.println("sql:"+sql);
		RecordSet rs = new RecordSet();
		rs.executeSql(sql);
		while (rs.next()){
			String dbwjbt=rs.getString(""+fieldid+"");
			int requestID=rs.getInt("requestId");
			//<a href="http://www.w3school.com.cn">W3School</a>
			result="<a href='/workflow/request/ViewRequest.jsp?requestid="+requestID+"' target='_blank'><font color='red'>该流程已经存在点击打开</a>";
			//return true;
		}
		System.out.println("result:"+result);
        response.setContentType("text/html");
        response.setCharacterEncoding("UTF-8");
        response.getWriter().print(result);
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        this.doGet(request, response);

    }
    
}